<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="shortcut icon" th:href="@{../../favicon.ico}" type="image/x-icon" />
    <link rel="stylesheet" th:href="@{../../assets/css/font.css}">
    <link rel="stylesheet" th:href="@{../../assets/css/xadmin.css}">
    <link rel="stylesheet" th:href="@{../../assets/lib/toast/css/toast.style.css}">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{../../assets/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{../../assets/js/xadmin.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{../../assets/lib/toast/js/toast.script.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{../../assets/lib/date/dateformat.js}" charset="utf-8"></script>
    <title>管理员-X-admin2.0</title>

</head>
<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>名称不能为空
            </div>
        </div>
        <div class="layui-form-item">
            <label for="isCode" class="layui-form-label">
                <span class="x-red">*</span>编码
            </label>
            <div class="layui-input-inline">
                <input type="text" id="isCode" name="isCode" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>编码不能为空
            </div>
        </div>
        <div class="layui-form-item">
            <label for="state" class="layui-form-label">
                <span class="x-red">*</span>状态
            </label>
            <div class="layui-input-inline" >
                <select id="state" name="state">
                    <option value="N">禁用</option>
                    <option value="Y">启用</option>
                </select>
            </div>
        </div>
        <br/>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button  type="submit" class="layui-btn layui-btn-fluid" lay-filter="*" lay-submit>
                提交
            </button>
        </div>

    </form>
</div>
<script>
    layui.use(['laydate','table','form'], function(){

        $ = layui.jquery;
        var laydate = layui.laydate,table = layui.table,form = layui.form;

        form.on('submit(*)', function(data){
            console.log(data.field);
            $.ajax({
                url: "/system/role/role-create.json",
                type:"POST",
                data :data.field,
                success: function(result){
                    if (result.status) {
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        layer.msg("操作成功");
                        parent.layer.close(index);  // 关闭layer
                        window.parent.location.reload(); //刷新父页面
                    }else{
                        layer.msg(result.msg);
                    }
                },
                error: function () {
                    layer.msg("修改错误，请联系开发人员进行排查");
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

    });
</script>
</body>

</html>